package ru.xpparty.scanner.model;

import ru.xpparty.scanner.PortRange;

/**
 * POJO(plain old java object) for request to scan
 */
public class ScanRequest {
    private final String host;
    private PortRange portRange;

    /**
     * Constructs new scan request by given host and port range
     * 
     * @param host given host
     * @param portRange given port range
     */
    public ScanRequest(String host, PortRange portRange) {
        this.host = host;
        this.portRange = portRange;
    }

    /**
     * 
     * @return host
     */
    public String getHost() {
        return host;
    }

    /**
     * 
     * @return start of port range
     */
    public int getStartPort() {
        return portRange.getStart();
    }
    
    /**
     * 
     * @return end of port range
     */
    public int getEndPort() {
        return portRange.getEnd();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        ScanRequest scanRequest = (ScanRequest) o;

        if (portRange.getStart() != scanRequest.getStartPort()) return false;
        if (portRange.getEnd() != scanRequest.getEndPort()) return false;
        if (!host.equals(scanRequest.host)) return false;

        return true;
    }  
}
